package br.com.foxline.atlasmobile.dao;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import br.com.foxline.atlasmobile.entities.Bairro;
import br.com.foxline.atlasmobile.entities.City;

import com.j256.ormlite.dao.GenericRawResults;

public class BairroDao extends GenericDao<Bairro>{

	private Context context;
	
	public BairroDao(Context context) {
		super(context, new Bairro());
	}

	public List<String> getBairros(City city){
		List<String> resul = new ArrayList<String>();
		GenericRawResults<String[]> rawResult;
		try {
			
			rawResult = getDao().queryBuilder().selectColumns("nome").where().eq("city_id", city.getId() ).queryRaw();
			
			for (String[] strings : rawResult) {
				resul.add(strings[0]);
			}
			
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
		return resul;
	}
}
